/*
 *  OrderDetailGoodsInfoListItem.java
 *  business
 *
 *  Created by SunDing on 2016/11/7.
 *
 *  Copyright (c) 2016年 yidiandao. All rights reserved.
 */

package com.yidiandao.business.ui.widget.listview.displaylistitem;

import android.app.Activity;
import android.content.Context;
import android.view.View;

import com.yidiandao.business.R;
import com.yidiandao.business.data.bean.Goods;
import com.yidiandao.business.ui.goodsdetail.GoodsDetailActivity;
import com.yidiandao.business.ui.widget.listview.DisplayListItem;
import com.yidiandao.business.ui.widget.listview.viewholder.OrderDetailGoodsInfoHolder;
import com.yidiandao.business.utils.ImageLoader;
import com.yidiandao.business.utils.UIUtils;

/** 订单详情 商品信息 */
public class OrderDetailGoodsInfoListItem
        extends DisplayListItem<OrderDetailGoodsInfoHolder, Goods> {

    public OrderDetailGoodsInfoListItem(Goods s) {
        super(s);
    }

    @Override
    public void onShow(final Context context, OrderDetailGoodsInfoHolder holder) {
        //商品图
        ImageLoader.loadImage(context, holder.mIvGoodsImage, data.getGoodsThumb());
        //商品名
        holder.mTvTitle.setText(data.getGoodsName());
        //价格
        holder.mTvSingelPrice.setText(data.getFormatedGoodsPrice());
        //数量
        holder.mTvCount.setText(
                UIUtils.getString(R.string.shopping_cart_count, data.getGoodsNumber()));
        //点击事件
        holder.mLlInfo.setOnClickListener(
                new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        String goodsId = data.getGoodsId();
                        GoodsDetailActivity.actionStart((Activity) context, goodsId);
                    }
                });
        if (null != data.getFavourableInfo()) {
            holder.mLlGoodsActiveInfo.setVisibility(View.VISIBLE);
            holder.mTvActiveTitle.setText(data.getFavourableInfo().getTitle());
            holder.mTvActiveInfo.setText(data.getFavourableInfo().getContent());
        } else {
            holder.mLlGoodsActiveInfo.setVisibility(View.GONE);
        }
    }

    @Override
    public String getDisplayItemTag() {
        return OrderDetailGoodsInfoListItem.class.getSimpleName();
    }

    @Override
    public Class<OrderDetailGoodsInfoHolder> getViewHolderClazz() {
        return OrderDetailGoodsInfoHolder.class;
    }
}
